<?php
class DigCms_View_Helper_DigCmsTitle extends Zend_View_Helper_Abstract
{
    public $titleFields = array('page_title', 'name');

    public function digCmsTitle(DigCms_Model_Item $item, $separator = ' - ') {
        $titleParts[] = DigCms_Service_Item::overloadContent($item, $this->titleFields);
        $parents = $item->parents();
        if($parents) {
            foreach ($parents as $parentItem) {
                $titleParts[] = DigCms_Service_Item::overloadContent($parentItem, $this->titleFields);
            }
        }
        foreach ($titleParts as $part) {
            $part = ucwords(str_replace('_', ' ', $part));
            $this->view->headTitle($part);
        }
        $this->view->headTitle()->setSeparator($separator);
    }
}
?>
